package ai.leinao.alarm.controller;

import ai.leinao.alarm.domain.RawAlarm;
import ai.leinao.alarm.limit.AlarmLimitProcessor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * description
 *
 * @author zhong.wang
 * @date 2025/9/4
 **/
@RestController
@RequestMapping("/alarm")
public class TestController {


    @Resource
    private AlarmLimitProcessor alarmLimitProcessor;


    @GetMapping("/test")
    public String test() {
        return "Application is running";
    }

    @GetMapping("/triggerAlarm")
    public void triggerAlarm(RawAlarm alarm) {
        alarm.setDerivedProperties(new HashMap<>());
        alarmLimitProcessor.reduceAndSendAlarm(alarm);
    }

}